Skip to content

Conversation

@dennisstritzke
Copy link
Contributor

Using the DEFAULT_TASK_BACKEND_ALIAS constant when referencing to the default task backend instead of repeating the string.

from .backends.base import BaseTaskBackend

DEFAULT_QUEUE_NAME = "default"
DEFAULT_TASK_BACKEND_ALIAS = "default"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am really not sure about the location of that constant. The locations where I wanted to put it produced circular imports, though...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is why I just duplicated it instead. Tests should cover if they're different.

@dennisstritzke dennisstritzke force-pushed the reference-default-backend-alias branch from 1447f9e to 4a623b0 Compare June 8, 2024 12:08
# Can be replaced with `django.conf.global_settings` once vendored.
return {
"default": {
DEFAULT_TASK_BACKEND_ALIAS: {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: As discussed, we should document that it should be called "default" (as with DATABASES).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But even if discarding the rest of the PR, we could still reference that variable instead of writing default again, right?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEFAULT_TASK_BACKEND_ALIAS isn't really part of the public API, so people shouldn't need to use it.

@dennisstritzke
Copy link
Contributor Author

This PR obviously isn't crucial for the projects success and mostly I question of taste. Looking at the alternatives, I would prefer using the constant in the non-test code as implemented by this PR.

If you agree, let's merge it. If you don't agree, feel free to close this PR. 🙃

@RealOrangeOne RealOrangeOne merged commit 001f609 into RealOrangeOne:master Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants